import os

# 检查文件扩展名是否允许
def allowed_file(filename):
    ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'mp3', 'mp4', 'avi', 'mov'}
    return '.' in filename and \
           filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS


def create_upload_directory(app):
    """确保上传目录存在"""
    os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)